<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>企业网站分类管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">分类管理</div>
                <div class="layui-card-body">
                    <div style="padding-bottom: 10px;">
                        <button class="layui-btn layuiadmin-btn-admin" data-type="batchdel">删除</button>
                        <a class="layui-btn layuiadmin-btn-admin" lay-href="/member/column/add.do?siteid=${siteId!}" lay-text="添加分类">添加</a>
                    </div>
                    <table class="layui-hide" id="column-treetable"></table>
                    <script type="text/html" id="column-table-setTpl">
                        <a class="layui-btn layui-btn-xs"><i class="layui-icon layui-icon-list"></i>类目内容</a>
                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-href="/member/column/edit.do?siteid=${siteId!}&id={{ d.id }}" lay-text="修改分类"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                        <a class="layui-btn layui-btn-xs" lay-href="/member/column/add.do?siteid=${siteId!}&parentId={{ d.id }}" lay-text="添加{{ d.columnTitle }}子分类"><i class="layui-icon layui-icon-add-1"></i>添加子类</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
<script>
    layui.config({
        base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
    }).extend({
        treetable: '../layui/treetable-lay/treetable',
        index: 'lib/index' //主入口模块
    }).use(['index','treetable', 'table',  'form'], function () {
        var table = layui.table
            , layer = layui.layer
            , form = layui.form
            , $ = layui.$
            , treetable = layui.treetable;
        //渲染表格
        var renderTable = function () {
            layer.load(2);
            treetable.render({
                id: 'column-treetable',
                treeColIndex: 1,	//树形图标显示在第几列
                treeSpid: '0',		//最上级的父级id
                treeIdName: 'id',	//id字段的名称
                treePidName: 'parentId',	//pid字段的名称，父级菜单id
                treeDefaultClose: true,	//是否默认折叠
                treeLinkage: false,		//父级展开时是否自动展开所有子级
                elem: '#column-treetable',	//表格id
                url: '/member/column/listData.do?siteid=${siteId!}',
                //toolbar: '#toolbarDemo',
                page: false,
                cellMinWidth: 120,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'columnTitle', title: '分类名称'},
                    {field: 'sortOrder', title: '排序', width: 120},
                    {fixed: 'right', align: 'center', title: '操作', toolbar: '#column-table-setTpl', width: 320}
                ]],
                //数据渲染完的回调
                done: function () {
                    //关闭加载
                    layer.closeAll('loading');
                }
            })
        };
        renderTable();

        //监听性别操作
        form.on('switch(test-table-visibleDemo)', function (obj) {
            var json = JSON.parse(decodeURIComponent($(this).data('json')));
            layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);
            json = table.clearCacheKey(json);
            console.log(json); //当前行数据
        });

        //监听锁定操作
        form.on('checkbox(test-table-lockDemo)', function (obj) {
            var json = JSON.parse(decodeURIComponent($(this).data('json')));
            layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);

            json = table.clearCacheKey(json);
            console.log(json); //当前行数据
        });

    });
</script>
</body>
</html>